package com.hzj.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hzj.pojo.Bookingrule;
import com.hzj.pojo.HospitalInfo;
import com.hzj.mapper.HospitalInfoMapper;
import com.hzj.service.BookingruleService;
import com.hzj.service.HospitalInfoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author hzj
 * @since 2021-04-26
 */
@Service
public class HospitalInfoServiceImpl extends ServiceImpl<HospitalInfoMapper, HospitalInfo> implements HospitalInfoService {
    @Autowired
    HospitalInfoMapper him;
    @Autowired
    BookingruleService bs;

    @Override
    public boolean updateAndSave(HospitalInfo hospitalInfo, Bookingrule bookingrule) {
        QueryWrapper wrapper = new QueryWrapper();
        wrapper.eq("hoscode", hospitalInfo.getHoscode());
        saveOrUpdate(hospitalInfo, wrapper);
        QueryWrapper wrapper1 = new QueryWrapper();
        wrapper.eq("hoscode", hospitalInfo.getHoscode());
        bs.saveOrUpdate(bookingrule, wrapper1);
        return false; //无所谓的返回值
    }

    @Override
    public HospitalInfo checkByHoscode(String hoscode) {
        return him.checkByHoscode(hoscode);
    }

    @Override
    public IPage getListPage(Page page1, Integer provinceCode, Integer cityCode,String hosname) {
        return him.getListPage(page1,provinceCode,cityCode,hosname);
    }

    @Override
    public HospitalInfo showHospDetail(int id) {
        return him.showHospDetail(id);
    }

    @Override
    public IPage getPageListByHostype(Page page1, Integer hostype, Integer districtCode) {
        return him.getPageListByHostype(page1,hostype,districtCode);
    }
}
